package com.xhrd.demo.web.validate;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;

import com.xhrd.demo.entities.DataDictionary;
import com.xhrd.framework.web.validator.BaseValidator;

public class DataDictionaryValidator extends BaseValidator<DataDictionary> {

    /**
     * serialUID
     */
    private static final long serialVersionUID = -2406641491136671686L;

    @Override
    public void validate(Object target, Errors errors) {
        super.validate(target, errors);

        // 必输验证
        ValidationUtils.rejectIfEmpty(errors, "type", "errors.required", new String[] { "字典类型" });
        ValidationUtils.rejectIfEmpty(errors, "key", "errors.required", new String[] { "字典键" });
        ValidationUtils.rejectIfEmpty(errors, "value", "errors.required", new String[] { "字典值" });

        if (errors.hasErrors()) {
            return;
        }

    }

}
